
/*
{
"状态":1,
"名称":"新增-权限导航树",
"作者":"马学兵",
"创建时间":"2018-08-20",
"功能":"新增-权限导航树",
"log": [
	{"date":"" , "dev" :"" , "content" : ""}
]
}
*/


DECLARE @power_tree_key int , @company_key int
DECLARE @tree_name nvarchar(400)
DECLARE @father_key int
DECLARE @displayindex smallint

Set @power_tree_key=''
Set @company_key='{company_key}'
Set @tree_name='{tree_name}'
Set @father_key='{father_key}'
Set @displayindex='{displayindex}'

select @power_tree_key=max(power_tree_key) from y_power_tree
set @power_tree_key=isnull(@power_tree_key,0)+1

if isnull(@tree_name,'')=''
begin
	RAISERROR ('SQL:名称不允许为空', 16 ,1 ) ; 
	return 
end 

if exists(select 1 from y_power_tree where tree_name=@tree_name)
begin
	RAISERROR ('SQL:名称已经存在', 16 ,1 ) ; 
	return 
end 

INSERT INTO [y_power_tree](company_key,power_tree_key,tree_name,father_key,displayindex,create_time) VALUES(@company_key,@power_tree_key,@tree_name,@father_key,@displayindex,getdate())